﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Application;
using Microsoft.AspNetCore.Mvc;

// For more information on enabling Web API for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860

namespace AuthorizationAPI.Controllers
{
    [Route("api/[controller]")]
    [ApiController]
    public class LoginController : ControllerBase
    {

        private readonly IAuthenticateService _authService;
        public LoginController(IAuthenticateService authService)
        {
            this._authService = authService;
        }

        // GET: api/<LoginController>
        [HttpGet]
        public IEnumerable<string> Get()
        {
            return new string[] { "value1", "value2" };
        }

        // GET api/<LoginController>/5
        [HttpGet("{id}", Name = nameof(Get))]
        public int Get(int id)
        {
            return id;
        }
        [HttpGet("Detail/{id}", Name = nameof(Detail))]
        public string Detail(int id)
        {
            return Guid.NewGuid().ToString();
        }
        // POST api/<LoginController>
        [HttpPost]
        public void Post([FromBody] string value)
        {
            Response.StatusCode = 404;
            return;
        }

        [HttpPost("LoginPost")]
        public string LoginPost([FromBody] LoginRequestDto loginDto)
        {
            return _authService.GetToken(loginDto);
        }
    }
}
